' R is the right angle
' r is opposite side
' r squared = x squared + y squared
' "aspect_ratio" is the height of a pixel vs the width, width always being = 1; this is a BAM compatibility thing for GW-BASIC screen modes

c_radius = 100
aspect_ratio = 1
c1x = 10 + c_radius     : c1y = 18 + c_radius
c2x = 20 + c_radius * 3 : c2y = c1y
iterations = 0
cpi = 100
tc_time = 0
c_time = 0
start_time = 0

SCREEN _NEWIMAGE(c_radius * 4 + 30, c_radius * 2 + 20, 12)

DO

    CLS

    start_time = timer
    FOR i = 1 TO cpi : GOSUB TCIRCLE : NEXT i
    tc_time = tc_time + timer - start_time

    start_time = timer
    FOR i = 1 TO cpi : CIRCLE (c2x, c2y), c_radius, 14 : NEXT i
    c_time = c_time + timer - start_time

    iterations = iterations + cpi
    LOCATE 0,0 : PRINT "count: " + iterations + " c1 time: " + INT(tc_time) + " c2 time: " + INT(c_time)
    _display

LOOP

END

TCIRCLE:

    FOR xy = 0 TO c_radius*0.75
        a = SQR( c_radius * c_radius - xy * xy )
        a_ar = a/aspect_ratio
        xy_ar = xy/aspect_ratio
        PSET (c1x + xy, c1y - a_ar), 14
        PSET (c1x - xy, c1y - a_ar), 14
        PSET (c1x + xy, c1y + a_ar), 14
        PSET (c1x - xy, c1y + a_ar), 14
        PSET (c1x - a, c1y + xy_ar), 14
        PSET (c1x - a, c1y - xy_ar), 14
        PSET (c1x + a, c1y + xy_ar), 14
        PSET (c1x + a, c1y - xy_ar), 14
    NEXT xy

RETURN